<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div id="formBox" class="wrapper wrapper-content animated fadeInRight ibox-content">
	<div class="form-horizontal m" id="form-user-add">
		<input id="id" name="id" :value="id" class="form-control"  type="hidden">
		<div class="form-group">
			<label class="col-sm-3 control-label ">身份证正面照：</label>
			<div class="col-sm-5" style="background: #e7eaec; padding-top:12px;">
				<div class="form-group">
					<div class="col-sm-12">
						<img id="certImgFont" :src="certImgFont" class="col-sm-12 " style="width: 100%;height: 100%;padding: 0 0;">
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label ">身份证背面照：</label>
			<div class="col-sm-5" style="background: #e7eaec; padding-top:12px;">
				<div class="form-group">
					<div class="col-sm-12">
						<img id="certImgBack" :src="certImgBack" class="col-sm-12 " style="width: 100%;height: 100%;padding: 0 0;">
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label ">用户姓名：</label>
			<div class="col-sm-5" style="background: #e7eaec; padding-top:12px;">
				<div class="form-group">
					<div class="col-sm-12">
						<input id="realname" class="form-control" type="text" :value="realname">
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label ">身份证号码：</label>
			<div class="col-sm-5" style="background: #e7eaec; padding-top:12px;">
				<div class="form-group">
					<div class="col-sm-12">
						<input id="idCardNum" class="form-control" type="text" :value="idCardNum">
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]]; var captchaType = [[${captchaType}]]; </script>
<script th:src="@{/js/vue.min.js}"></script>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/ajaxupload.js}"></script>
<div th:include="include::footer"></div>
<script>
    var viewAlert = $.modal;
    var modelBean= {};
    var vm = new Vue({
        el: '#formBox',
        data: {
            id:'[[${thisUser.id}]]',
            certImgFont: ctx + ('[[${thisUser.certImgFont}]]' ? '[[${thisUser.certImgFont}]]' : 'img/no_img.png'),
            certImgBack: ctx + ('[[${thisUser.certImgBack}]]' ? '[[${thisUser.certImgBack}]]' : 'img/no_img.png'),
            realname:'[[${thisUser.realname}]]'
        },
        methods: {
        }
    });

    $(function () {
        new AjaxUpload('#certImgFont', {
            action: ctx + 'admin/file/upload',
            name: 'file',
            data: {
                logic: 'set_pay_img',
                type: 'auth',
                state: '0',
                puth:'11'
            },
            autoSubmit: true,
            responseType: "json",
            onSubmit: function (file, extension) {
                if (!(extension && /^(jpg|jpeg|png|gif)$/.test(extension.toLowerCase()))) {
                    alert('只支持jpg、png、gif格式的图片！');
                    return false;
                }
            },
            onComplete: function (file, r) {
                if (r.code == 0) {
                    vm.certImgFont = ctx + r.url;
                    modelBean.certImgFont = r.url;
                } else {
                    alert(r.msg);
                }
            }
        });
        new AjaxUpload('#certImgBack', {
            action: ctx + 'admin/file/upload',
            name: 'file',
            data: {
                logic: 'set_pay_img',
                type: 'auth',
                state: '0',
                puth:'11'
            },
            autoSubmit: true,
            responseType: "json",
            onSubmit: function (file, extension) {
                if (!(extension && /^(jpg|jpeg|png|gif)$/.test(extension.toLowerCase()))) {
                    alert('只支持jpg、png、gif格式的图片！');
                    return false;
                }
            },
            onComplete: function (file, r) {
                if (r.code == 0) {
                    vm.certImgBack = ctx + r.url;
                    modelBean.certImgBack = r.url;
                } else {
                    alert(r.msg);
                }
            }
        });
    });
    function submitHandler() {
        modelBean.id = $("#id").val();
        modelBean.realname = $("#realname").val();
        $.ajax({
            type: "POST",
            url: ctx + "manager/user/user_auth",
            data: modelBean,
            dataType: "json",
            success: function (result) {
                if (result.code == 0) {//登录成功
                    viewAlert.close();
                } else {
                    alert(result.msg);
                }
            }
        });
    }
</script>
</body>
</html>
